package com.example.springboot.controller;

import com.example.springboot.entity.Animal;
import com.example.springboot.mapper.AnimalMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/animal")
public class AnimalController {
    @Autowired
    private AnimalMapper animalMapper;

    //插入信息
    @PostMapping
    public Integer save(){
        animalMapper.insert();
    }

    //查询
    @GetMapping
    public List<Animal> index(){
        return animalMapper.findAll();
    }
}
